package com.willian.andrappfw.ui;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.willian.andrappfw.R;
import com.willian.andrappfw.utils.UIUtils;
import com.willian.andrappfw.utils.Utils;


public abstract class BaseDialog extends Dialog {

    public BaseDialog(@NonNull Context context) {
        super(context, R.style.CustomResultDialog);
    }


    /**
     * 初始化界面控件
     */
    protected abstract void initView();

    /**
     * 初始化界面控件的显示数据
     */
    protected abstract void refreshView();


    @Override
    public void show() {
        super.show();

        if (getWindow() == null){
            return;
        }
        final WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.gravity = Gravity.BOTTOM;
        params.height = Utils.getScreenHeight() - UIUtils.dip2px(getContext(),50) - Utils.getStatusBarHeight();
        getWindow().setAttributes(params);
    }
}
